package com.squirrel.michale;

/**
 * @author guanhao 观浩
 * @version 1.0.0.0
 * @createTime 2023/2/27 9:14 PM
 * @company Michale Squirrel
 * @link
 * @description
 */
public class LeetCode2181 {

    public ListNode mergeNodes(ListNode head) {
        ListNode dummy=new ListNode(-1);
        ListNode tail=dummy;
        int sum=0;
        while(head!=null){
            sum+=head.val;
            if(head.val==0&&sum!=0){
                tail.next=new ListNode(sum);
                tail=tail.next;
                sum=0;
            }
            head=head.next;
        }
        return dummy.next;
    }
}
